﻿
@{
    ViewBag.Title = "新增城市";
}

<article class="page-container">
    <form class="form form-horizontal" id="form">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>城市名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="name" name="name">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-success radius" id="admin-City-save" name="admin-City-save"><i class="icon-ok"></i> 确定</button>
            </div>
        </div>
    </form>
</article>

@section FooterScript
{
    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript" src="~/Areas/WebAdmin/FrontLib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="~/Areas/WebAdmin/FrontLib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="~/Areas/WebAdmin/FrontLib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#form").validate({
                rules: {
                    name: {
                        required: true
                    },
                },
                onkeyup: false,
                focusCleanup: true,
                success: "valid",
                submitHandler: function (form) {
                    $(form).ajaxSubmit({
                        type: 'POST',
                        url: "/WebAdmin/City/Add",
                        success: function (res) {
                            if (res.status == "ok") {
                                parent.layer.msg('新增成功!', { icon: 1, time: 1000 }, function () {
                                    parent.$('.btn-refresh').click();
                                    //parent.location.reload(); //刷新父页面
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                });
                            } else if (res.status == "redirect") {
                                location.href = res.data;
                            } else if (res.status == "error") {
                                layer.msg(res.errorMsg, { icon: 2, time: 1000 });
                            }else {
                                layer.msg("新增失败", { icon: 2, time: 1000 });
                            }
                        },
                        error: function (XmlHttpRequest, textStatus, errorThrown) {
                            layer.msg('网络出错!', { icon: 2, time: 1000 });
                        }
                    });
                }
            });
        });
    </script>
    <!--/请在上方写此页面业务相关的脚本-->
}
